<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.util.*,com.pub.database.*" %>

<%
	ArrayList<ArrayList<Object>> altEmpList = null;
	ArrayList<Object> altEmpListData = null;

   QueryBean qbnDAO=null;

   try{
     if(request.getParameter("deptno")==null || request.getParameter("deptno").trim().equals("")){
       return;
     }

     qbnDAO=new QueryBean(request.getParameter("DB_ALIAS"),Boolean.valueOf(request.getParameter("DEBUG")).booleanValue(), request.getParameter("SOURCE_CHARSET"), request.getParameter("TARGET_CHARSET"));

     StringBuffer stbSQL=new StringBuffer("select e.employee_no,e.employee_name_c,e.employee_name_e,e.dept_no,b.dept_name,e.fact_no,e.class_code,c.class_name,(select max(employee_tel) from pnl_tel where employee_no=e.employee_no) ");
     stbSQL.append("from pnl_employee e,bas_dept b,pnl_work c ");
     stbSQL.append("where e.employee_st='A' ");
     stbSQL.append("and b.dept_no=e.dept_no ");
     stbSQL.append("and e.dept_no='");
     stbSQL.append(request.getParameter("deptno"));
     stbSQL.append("' and e.class_code=c.class_code ");
     stbSQL.append(" order by e.employee_no ");
     //stbSQL.append("group by level,dept_no,dept_up,dept_name ");
     //stbSQL.append("start with dept_up = '01000000' connect by prior dept_no = dept_up");

     altEmpList=qbnDAO.querySQL(stbSQL.toString());
%>
<html>

<head>
  <LINK HREF="workflow.css" REL="STYLESHEET" TYPE="TEXT/CSS"/>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>人員列表</title>
</head>
<body>
  <%if(altEmpList==null){out.println("無人員歸屬此部門");return;} %>
  <table>
    <%for(int i=0;i<=altEmpList.size()-1;i++){ %>
      <%altEmpListData=(ArrayList<Object>)altEmpList.get(i); %>
      <tr>
        <td><a href="EmployeeList.jsp" onclick="javascript:parent.retVal('<%=altEmpListData.get(0).toString() %>','<%=altEmpListData.get(1).toString() %>','<%=altEmpListData.get(2).toString() %>','<%=altEmpListData.get(3).toString() %>','<%=altEmpListData.get(4).toString() %>','<%=altEmpListData.get(5).toString() %>','<%=altEmpListData.get(6).toString() %>','<%=altEmpListData.get(7).toString() %>');"><%=altEmpListData.get(0).toString() %></a></td>
        <td><%=altEmpListData.get(1).toString() %></td>
      </tr>
    <%}%>
  </table>
</body>
</html>
<%
   }
   catch(Exception e){
     e.printStackTrace();
   }
   finally{
     try{qbnDAO.close();}catch(Exception e){e.printStackTrace();}
     if(altEmpList!=null){
       altEmpListData.clear();
       altEmpList.clear();
     }

     altEmpListData=null;
     altEmpList=null;
     qbnDAO=null;
   }
%>
